/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package pt.iasd.youthshelter.datamodel;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Rui
 */
@Entity
@Table(name = "CLUB")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Club.findAll", query = "SELECT c FROM Club c"),
    @NamedQuery(name = "Club.findById", query = "SELECT c FROM Club c WHERE c.id = :id"),
    @NamedQuery(name = "Club.findByName", query = "SELECT c FROM Club c WHERE c.name = :name")})
public class Club implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "ID")
    private Integer id;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 30)
    @Column(name = "NAME")
    private String name;
    @ManyToMany(mappedBy = "clubList")
    private List<Activity> activityList;
    @JoinTable(name = "PROGRESSIVE_CLASS_CLUB", joinColumns = {
        @JoinColumn(name = "CLUB_ID", referencedColumnName = "ID")}, inverseJoinColumns = {
        @JoinColumn(name = "CLASS_ID", referencedColumnName = "ID")})
    @ManyToMany
    private List<ProgressiveClass> progressiveClassList;
    @ManyToMany(mappedBy = "clubList")
    private List<Investiture> investitureList;
    @JoinTable(name = "HONOR_CLUB", joinColumns = {
        @JoinColumn(name = "CLUB_ID", referencedColumnName = "ID")}, inverseJoinColumns = {
        @JoinColumn(name = "HONOR_ID", referencedColumnName = "ID")})
    @ManyToMany
    private List<Honor> honorList;

    public Club() {
    }

    public Club(Integer id) {
        this.id = id;
    }

    public Club(Integer id, String name) {
        this.id = id;
        this.name = name;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @XmlTransient
    public List<Activity> getActivityList() {
        return activityList;
    }

    public void setActivityList(List<Activity> activityList) {
        this.activityList = activityList;
    }

    @XmlTransient
    public List<ProgressiveClass> getProgressiveClassList() {
        return progressiveClassList;
    }

    public void setProgressiveClassList(List<ProgressiveClass> progressiveClassList) {
        this.progressiveClassList = progressiveClassList;
    }

    @XmlTransient
    public List<Investiture> getInvestitureList() {
        return investitureList;
    }

    public void setInvestitureList(List<Investiture> investitureList) {
        this.investitureList = investitureList;
    }

    @XmlTransient
    public List<Honor> getHonorList() {
        return honorList;
    }

    public void setHonorList(List<Honor> honorList) {
        this.honorList = honorList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Club)) {
            return false;
        }
        Club other = (Club) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "pt.iasd.youthshelter.datamodel.Club[ id=" + id + " ]";
    }
    
}
